package org.zhaijisong.Controller;

import Publics.ResponseResUlt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zhaijisong.dao.UserDao;
import org.zhaijisong.pojo.Staff;
import org.zhaijisong.pojo.User;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/WebPage")
@CrossOrigin(value = "*")
public class LoginController {
    @Autowired
    private UserDao userDao;
    @RequestMapping("/logins")
    @ResponseBody
    public ResponseResUlt<User> denglu(String user,String password) {
        Map<String,Object> map = new HashMap<>();
        User u = userDao.logins(user);
        if(u==null){
            return new ResponseResUlt(1,"没有此账号");
        }else{
            String psg=password;
            //ps=new Md5Hash(password,s.getSalt()).toString();
            if(!psg.equals(u.getPassword())){
                return new ResponseResUlt(1,"密码错误");
            }
        }

        map.put("user_login",u);
        ResponseResUlt<User> results=new ResponseResUlt(u);

        return results;
    }
}
